import * as express from 'express';
interface Demo{
    name:string;
    id:number;
}
const demos:Array<Demo> = [
    {
        name:'dlc',
        id:2
    },
    {
        name:'dlc2',
        id:3
    }
]
/**
 * 声明http服务的
 */
const app = express();

// 获取get请求
app.get('/', (req, res)=>{
    res.json(demos);
});

// 获取请求参数
app.get('/arguments/:id', (req, res)=>{
    res.send(req.params.id);
    // ?a=1&b=1 通过query去拿 req.query.a
});

/**
 * 启动server
 */
const server = app.listen(8080, '192.168.1.105', ()=>{
    // 事件回调，当服务启动回调此
    console.log('localhost:8080' + '-status:staring...');
});



